<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <h1>{{msg}}</h1>
    <form action="###">
      <!-- 使用.trim修饰符可以去掉空格 -->
      username: <input type="text" name="username" v-model.trim="userInfo.name">
      <!--输入框是实时收集数据, 使用.lazy修饰符等到输入框失去焦点的时候才会收集数据 类比js的input和change事件-->
      password: <input type="password" name="password" v-model.lazy="userInfo.pas">
      <!-- 使用.number可以数据转为number类型,如果无法转换,则继续保持字符串形式 -->
      phoneNumber: <input type="text" name="phoneNumber" v-model.number="userInfo.num">
      <br>
      <p>选择你喜欢的动物(多选)</p>
      <input type="checkbox" name="dog" v-model="userInfo.dog" value="大佐">大佐
      <input type="checkbox" name="dog" v-model="userInfo.dog" value="喵桑">喵桑
      <input type="checkbox" name="dog" v-model="userInfo.dog" value="撒库拉">撒库拉
    </form>
  </div>
  <script>
    Vue.config.productionTip = false;
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          msg: "hello vue!",
          userInfo: {
            name: '',
            pas: '',
            num: null,
            dog: []
          },

        }
      },
      methods: {}
    })
  </script>
</body>

</html>